import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { HttpModule, Http } from '@angular/http';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { SuperTabsModule } from 'ionic2-super-tabs';
import { Toast } from '@ionic-native/toast';
import { File } from '@ionic-native/file';
import { Camera } from '@ionic-native/camera';
import { Transfer } from '@ionic-native/transfer';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { ImagePicker } from '@ionic-native/image-picker';
import { Network } from '@ionic-native/network';
import { AppMinimize } from "@ionic-native/app-minimize";
import { NativeStorage } from '@ionic-native/native-storage';
import { IonicStorageModule } from '@ionic/storage';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { SQLite } from '@ionic-native/sqlite';
import { Zip } from '@ionic-native/zip';
import { BarcodeScanner } from '@ionic-native/barcode-scanner';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { ActivatePage } from '../pages/activate/activate';
import { LoginPage } from '../pages/login/login';
import { ListPage } from '../pages/list/list';
import { TableListPage } from '../pages/table-list/table-list';
import { CurrentOrderPage } from '../pages/current-order/current-order';
import { ProductListPage } from '../pages/product-list/product-list';
import { ProductOptionModalPage } from '../pages/product-option-modal/product-option-modal';
import { ProductOptionListPage } from '../pages/product-option-list/product-option-list';
import { OrderHistoryPage } from '../pages/order-history/order-history';
import { SettingsPage } from '../pages/settings/settings';
import { SettingsModePage } from '../pages/settings-mode/settings-mode';
import { SettingsGeneralPage } from '../pages/settings-general/settings-general';
import { SettingsLanguagePage } from '../pages/settings-language/settings-language';
import { SettingsPrintPage } from '../pages/settings-print/settings-print';
import { ServerQrCodePage } from '../pages/server-qr-code/server-qr-code';

import { HelperService } from '../providers/services.helper';
import { ApiService } from '../providers/services.api';
import { OfflineService } from '../providers/services.offline';
import { PrinterService } from '../providers/services.printer';
import { GlobalData } from '../providers/GlobalData';

export function createTranslateLoader(http: Http) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    MyApp,
    ActivatePage,
    HomePage,
    LoginPage,
    ListPage,
    TableListPage,
    CurrentOrderPage,
    ProductListPage,
    ProductOptionModalPage,
    ProductOptionListPage,
    OrderHistoryPage,
    SettingsPage,
    SettingsModePage,
    SettingsGeneralPage,
    SettingsLanguagePage,
    SettingsPrintPage,
    ServerQrCodePage
  ],
  imports: [
    BrowserModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: (createTranslateLoader),
        deps: [Http]
      }
    }),
    IonicModule.forRoot(MyApp, {
      mode: 'ios'
    }),
    SuperTabsModule.forRoot(),
    IonicStorageModule.forRoot(),
    HttpModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    ActivatePage,
    HomePage,
    LoginPage,
    ListPage,
    TableListPage,
    CurrentOrderPage,
    ProductListPage,
    ProductOptionModalPage,
    ProductOptionListPage,
    OrderHistoryPage,
    SettingsPage,
    SettingsModePage,
    SettingsGeneralPage,
    SettingsLanguagePage,
    SettingsPrintPage,
    ServerQrCodePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    HelperService,
    Toast,
    Camera,
    File,
    Transfer,
    InAppBrowser,
    ImagePicker,
    Network,
    AppMinimize,
    NativeStorage,
    SQLite,
    Zip,
    BarcodeScanner,
    ApiService,
    OfflineService,
    PrinterService,
    GlobalData
  ]
})
export class AppModule { }
